package lib;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Random;


public class Test_MeteorFly extends JFrame  {
    static int width;
    static int height;
    public static void main(String[] args) throws IOException {

        Test_MeteorFly jframe = new Test_MeteorFly();
        jframe.setTitle("love");
        jframe.add(new MyPanel());
        jframe.setSize(width,height);
        jframe.setVisible(true);
    }
    static class MyPanel extends JPanel{
        BufferedImage image;
        public MyPanel() throws IOException {
            //setBackground(Color.black);
            image =ImageIO.read(new File("01610455e6d1ed6ac7251df8bdd1b0.jpg@1280w_1l_2o_100sh.jpg"));
            width=image.getWidth();
            height=image.getHeight();
            Star star=new Star();
            Graphics g=image.getGraphics();
            g.setColor(star.color);
            g.fillRect(star.x,star.y,star.size,star.size);
        }
        public void paint(Graphics g){
            super.paint(g);
            g.drawImage(image,0,0,null);
        }
    }

    static class Star{
        Color color=Color.white;
        int size=2;
        int x,y;
        public Star(){
            reset();
        }
        Random r =new Random();
        public void reset(){
            int number=r.nextInt(10);
            if(number>3){
                y=0;
                x=r.nextInt(200);
            }else {
                x=0;
                y=r.nextInt(200);
            }
        }

    }
}
